pub mod entity;
pub mod model;
pub mod rbac_role_resource_rel_dal;
pub mod rbac_user_role_rel_dal;
pub mod resource_dal;
pub mod role_dal;
pub mod user_dal;

pub use model::UserStatus;
pub use rbac_role_resource_rel_dal::RbacRoleResourceRelQuery;
pub use rbac_user_role_rel_dal::RbacUserRoleRelQuery;
pub use resource_dal::ResourceQuery;
pub use role_dal::RoleQuery;
pub use user_dal::UserQuery;

#[cfg(test)]
mod tests {
    use axum_app_common::test::get_connect;
    use axum_app_common::{query_page, QueryPageCondition};
    use sea_orm::sea_query::IntoCondition;
    use sea_orm::{ColumnTrait, Condition, EntityTrait, Order};

    use crate::entity::rbac_role_resource_rel;

    #[tokio::test]
    async fn test_query_page() {
        pub struct MyPageCondition {
            filter: Condition,
            order_by: Vec<(rbac_role_resource_rel::Column, Order)>,
        }

        impl QueryPageCondition<rbac_role_resource_rel::Column> for MyPageCondition {
            fn filter(&self) -> Condition {
                self.filter.clone()
            }

            fn order_by(&self) -> Vec<(rbac_role_resource_rel::Column, Order)> {
                self.order_by.clone()
            }
        }

        let cond = MyPageCondition {
            filter: Condition::all(),
            order_by: vec![],
        };

        let db = get_connect().await;

        let query = query_page(&db, rbac_role_resource_rel::Entity::find(), 1, 20, &cond).await;

        let resp = query.unwrap();

        println!("list={:?}", resp);
    }
}
